#include <stdio.h>
#include <e_file.h>

#define BUFFSIZE 32
int main (int argc, char ** argv)
{
	int fd = 0;
	int cnt = 0;
	char buf[BUFFSIZE] = {0};
	if (argc < 2) {
		return -1;
	}
	//打开argv[1]文件
	fd = open (argv[1], O_RDONLY);
	if (-1 == fd) {
		//fprintf (stderr, "open() failed!\n");
		perror("open()");
	}
	while (1) {
		cnt = read (fd, buf, BUFFSIZE);
		if (-1 == cnt) {
			//fprintf (stderr, "read() failed!\n");
			perror ("read()");
			goto ERROR;
		}
		if (0 == cnt) {
			break;
		}
		write (1, buf, cnt);
	}
	close (fd);
	return 0;
ERROR:
	close (fd);
	return -1;
}
